Preparation


In [ ]:
%run "../Functions/4. User comparison.ipynb"

Data vectors of users


In [ ]:
# small sample
#allData = getAllUserVectorData( getAllUsers()[:10] )

# complete set
#allData = getAllUserVectorData( getAllUsers() )

# subjects which answered the gform
#allData = getAllUserVectorData( getAllResponders()[:10] )
allData = getAllUserVectorData( getAllResponders() )

In [ ]:
allData

Graphs


In [ ]:
columnAllData = allData.T
columnAllData['scorebefore'][:5]

In [ ]:
plt.plot(columnAllData['craft'], columnAllData['equip'], 'ro')
plt.xlabel('craft')
plt.ylabel('equip')

In [ ]:
plt.plot(columnAllData['sessionsCount'], columnAllData['craft'], 'ro')
plt.xlabel('sessionsCount')
plt.ylabel('craft')

In [ ]:
columnAllData.columns

In [ ]:
for column in columnAllData.columns:
    print(column)

In [ ]:
columnAllData.columns[1]

In [ ]:
len(columnAllData.columns)

In [ ]:
for i in range(1,len(columnAllData.columns)):
    for j in range(i+1,len(columnAllData.columns)):
        print(i,j)
        print(columnAllData.columns[i], columnAllData.columns[j])

In [ ]:
def plotFromAllUsersData(allUsersData, xcolumnname, ycolumnname):
    plt.title("plotting '" + ycolumnname + "' against '" + xcolumnname + "'")
    plt.plot(
                allUsersData[xcolumnname],
                allUsersData[ycolumnname],
                'ro'
            )
    plt.xlabel(xcolumnname)
    plt.ylabel(ycolumnname)
    #plt.show()

In [ ]:
plotFromAllUsersData(
                        columnAllData,
                        columnAllData.columns[1],
                        columnAllData.columns[2]
                    )

Subplot tests


In [ ]:
plt.figure(1)

#plt.subplot(131)
plt.subplot(311)
plotFromAllUsersData(
                        columnAllData,
                        columnAllData.columns[2],
                        columnAllData.columns[3]
                    )

plt.grid(True)

#plt.subplot(132)
plt.subplot(321)
plotFromAllUsersData(
                        columnAllData,
                        columnAllData.columns[2],
                        columnAllData.columns[4]
                    )
plt.grid(True)

#plt.subplot(133)
plt.subplot(331)
plotFromAllUsersData(
                        columnAllData,
                        columnAllData.columns[2],
                        columnAllData.columns[5]
                    )
plt.grid(True)

plt.subplots_adjust(top=0.92, bottom=0.08, left=0.10, right=0.95, hspace=0.25,
                    wspace=0.35)

plt.show()

In [ ]:
fig = plt.figure()

ax1 = fig.add_subplot(221)
ax1.plot([1,2,3,4,5], [10,5,10,5,10], 'r-')

ax2 = fig.add_subplot(222)
ax2.plot([1,2,3,4], [1,4,9,16], 'k-')

ax3 = fig.add_subplot(223)
ax3.plot([1,2,3,4], [1,10,100,1000], 'b-')

ax4 = fig.add_subplot(224)
ax4.plot([1,2,3,4], [0,0,1,1], 'g-')


plt.tight_layout()
fig = plt.gcf()

In [ ]:
fig = plt.figure(figsize=(16,4))


ax1 = fig.add_subplot(131)
ax1.plot([1,2,3,4,5], [10,5,10,5,10], 'r-')


ax2 = fig.add_subplot(132)
ax2.plot([1,2,3,4], [1,4,9,16], 'k-')


ax3 = fig.add_subplot(133)
ax3.plot([1,2,3,4], [1,10,100,1000], 'b-')


plt.tight_layout()

fig = plt.gcf()

In [ ]:
def subplotFromAllUsersData(ax, allUsersData, xcolumnname, ycolumnname):
    plt.title("'" + str(ycolumnname) + "' against '" + str(xcolumnname) + "'")
    ax.plot(
                allUsersData[xcolumnname],
                allUsersData[ycolumnname],
                'ro'
            )
    plt.xlabel(xcolumnname)
    plt.ylabel(ycolumnname)
    #plt.show()

In [ ]:
fig = plt.figure(figsize=(16,4))


ax1 = fig.add_subplot(131)
subplotFromAllUsersData(
                        ax1,
                        columnAllData,
                        columnAllData.columns[2],
                        columnAllData.columns[3]
                    )


ax2 = fig.add_subplot(132)
subplotFromAllUsersData(
                        ax2,
                        columnAllData,
                        columnAllData.columns[2],
                        columnAllData.columns[4]
                    )


ax3 = fig.add_subplot(133)
subplotFromAllUsersData(
                        ax3,
                        columnAllData,
                        columnAllData.columns[2],
                        columnAllData.columns[5]
                    )


plt.tight_layout()

fig = plt.gcf()

In [ ]:
for i in range(0,6):
    position = 131 + (i % 3)

    if i % 3 == 0:
        fig = plt.figure(figsize=(16,4))

    ax1 = fig.add_subplot(position)
    subplotFromAllUsersData(
                            ax1,
                            columnAllData,
                            columnAllData.columns[2],
                            columnAllData.columns[3+i]
                        )

Automation tests


In [ ]:
len(columnAllData.columns)

In [ ]:
graphsCount = len(columnAllData.columns) * (len(columnAllData.columns) - 1) / 2
graphsCount

TODO FIXME

1 column of graphs

graphsProgressBar = FloatProgress(min=0, max=graphsCount) display(graphsProgressBar) graphsProgressBar.value = 0 for i in range(0,len(columnAllData.columns)): xcolumnname = columnAllData.columns[i] for j in range(i+1,len(columnAllData.columns)): ycolumnname = columnAllData.columns[j] plotFromAllUsersData(columnAllData, xcolumnname, ycolumnname) graphsProgressBar.value += 1 print("done in " + str(graphsProgressBar.value) + " steps.")

3 columns of graphs


In [ ]:
graphsProgressBar = FloatProgress(min=0, max=graphsCount)
display(graphsProgressBar)
graphsProgressBar.value = 0
for i in range(0,len(columnAllData.columns)):
    xcolumnname = columnAllData.columns[i]
    for j in range(i+1,len(columnAllData.columns)):
        ycolumnname = columnAllData.columns[j]
        
        # actual plotting
        position = 131 + (graphsProgressBar.value % 3)

        if graphsProgressBar.value % 3 == 0:
            fig = plt.figure(figsize=(16,4))

        ax = fig.add_subplot(position)
        subplotFromAllUsersData(
                                ax,
                                columnAllData,
                                xcolumnname,
                                ycolumnname
                            )
        
        graphsProgressBar.value += 1
print("done in " + str(graphsProgressBar.value) + " steps.")